class Person {
  protected name: string;
  constructor(name: string) {
    this.name = name;
  }
}

class Teacher extends Person {
  private project: string;
  constructor(name: string, project: string) {
    super(name);
    this.project = project;
  }

  work() {
    console.log(this.name + '正在工作');
  }
}

let peter: Person = new Person('peter');
// console.log(peter.name); // 只能在类及子类中访问

let mali: Teacher = new Teacher('mali', 'math');
// console.log(mali.name); // 只能在类及子类中访问
mali.work();

class Engineer {
  constructor(private name: string, private project: string) {}
  work() {
    console.log(this.name + '正在从事' + this.project + '工作');
  }
}

let pual: Engineer = new Engineer('Pual', 'SoftWare');
pual.work();


class Chef {
  private constructor(private project: string) {}
}

// let david: Chef = new Chef('fish'); // 不可实例化